package com.wei.tools;

import java.sql.DriverManager;
import java.sql.*;

/**
 * @author 魏小杭
 */
public class DBconn {
    //定义数据库连接对象
    private static Connection conn=null;
    //定义数据库连接字符串
    private static final String url="jdbc:mysql://localhost/wei";
    private static final String user="root";
    private static final String password="611611";

    /**
     * 数据库连接方法
     * @return
     */
    public static Connection getConn(){
        try {
            //1.加载驱动
            Class.forName("com.mysql.jdbc.Driver");
            //2.获取连接对象
            conn= DriverManager.getConnection(url, user, password);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;

    }
}
